<template>
	<view class="content">
		<view class="head-title">
			<view class="title" style="color:#FFFFFF;font-size: 36upx;">{{ title }}</view>
			<view class="title-sow">购物币总数</view>

			<view class="tilte-soe">{{ passcard.gouwubi }}</view>
			<button type="none"  class="btn1" @click="cash_in">转账</button>
			<!-- <button type="none" class="btn2" @click="encourage">充值</button> -->
		</view>
		<!-- 购物币转出 -->
		<view class="tou">
			<view class="row" v-for="(row, index) in couponValidList" :key="index">
				<view class="one">
					<view class="title">{{ row.title }}</view>
					<view class="term">{{arr[index]}}</view>
				</view>
				<view class="jifen">
					<view style="float: left;">
						<view v-if="row.type==1 || row.type==2 ">+</view>
						<view v-else>-</view>
					</view>
					<view style="float: left;">{{ row.gouwubi }}</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			title: '我的购物币',
			passcard: '',
			couponValidList: [],
			arr:[],
			arr66: [],
		};
	},
	onLoad() {
		this.data1()
	},
	onShow() {
		this.data1()
	},
	methods: {
		time(ytime){
			var date = new Date(ytime * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
			var Y = date.getFullYear() + '-';
			var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
			var D = date.getDate() + ' ';
			var h = date.getHours() + ':';
			var m = date.getMinutes() + ':';
			var s = date.getSeconds();
			let timeer = Y + M + D + h + m + s ;
			return timeer
		},
		data1(){
			uni.request({
				url: 'http://tuiguang.yiyunoto.com/api/member/mem_gouwubi',
				header: { authtoken: this.$store.state.token },
				method: 'POST',
				success: res => {
					let arr = [];
					console.log('11请求成功', res);
					this.passcard = res.data.data.passcard;
					this.couponValidList = res.data.data.list;
					for (let i = 0; i < res.data.data.list.length; i++) {
							this.arr.push(this.time(res.data.data.list[i].updatetime));
					}
					uni.stopPullDownRefresh();
					console.log(this.arr66, 'arr66');
				},
				fail: res => {
					console.log('请求失败', res);
				}
			});
		},
		onPullDownRefresh: function() {
			this.data1()
		},
		cash_in() {
			uni.navigateTo({
				url: '../transfer/transfer'
			});
		},
		encourage(e) {
			uni.redirectTo({
				url: '../Exchange_option/index'
			});
		}
	}
};
</script>

<style>
.content {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background: #f1f1f1;
}

.head-title {
	width: 100%;
	height: 470upx;
	padding-top: 50upx;
	background: #42a8ff;
}
.title {
	display: flex;
	justify-content: center;
	font-size: 36upx;
	padding-top: 30upx;
	color: #ffffff;
}
.title-sow {
	font-size: 40upx;
	/* position: absolute; */
	margin-left: 40upx;
	margin-top: 80upx;
	color: #ffffff;
}
.tilte-soe {
	font-size: 80upx;
	/* position: absolute; */
	margin-left: 40upx;
	margin-top: 10upx;
	color: #ffffff;
}
.btn1 {
	width: 160upx;
	border-radius: 40upx;
	background:rgba(104, 185, 255, 0.8);
	color: #FFFFFF;
	box-shadow: #868686 3upx 3upx !important;
	line-height: 80upx;
	float: left;
	margin-top: 30upx;
	margin-left: 30upx;
	text-align: center;
}
.btn2 {
	width: 160upx;
	float: right;
	color: #FFFFFF;
	margin-top: 30upx;
	margin-right: 30upx;
	border-radius: 40upx;
	background: rgba(104, 185, 255, 0.8);
	box-shadow: #868686 3upx 3upx !important;
	line-height: 80upx;
	text-align: center;
}
/* 循环列表 */
.tou {
	width: 100%;
	height: 0upx;
}
.one {
	float: left;
}
.row {
	width: 100%;
	height: 143upx;
	background: #ffffff;
	margin-top: 2upx;
	border-bottom-width: 1upx;
	border-bottom-style: solid;
	border-bottom-color: #ededed;
}
.title {
	font-size: 32upx;
	font-family: PingFangSC-Regular, PingFangSC;
	color: rgba(41, 41, 41, 1);
	padding-left: 30upx;
	padding-top: 30upx;
}
.term {
	font-size: 26upx;
	font-family: PingFangSC-Regular, PingFangSC;
	color: rgba(127, 127, 127, 1);
	padding-left: 30upx;
	padding-top: 1upx;
}
.jifen {
	font-size: 41upx;
	font-family: PingFangSC-Regular, PingFangSC;
	color: rgba(51, 51, 51, 1);
	padding-left: 510upx;
	padding-top: 43upx;
}
</style>
